<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;

use Illuminate\Support\Facades\Auth;

use Illuminate\Support\Facades\DB;

use Illuminate\Http\Request;

class IncomeController extends Controller
{

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth:admin');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //查询用户游戏数据
        $income_record = DB::table('income_record')
            ->select('id', 'code', 'ip', 'address', 'single', 'money', 'time', 'income_person')
            ->where(function ($query) {
                $query->orWhere('code', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('ip', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('address', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('single', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('money', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('time', 'like', '%'.@$_GET['search'].'%');
                $query->orWhere('income_person', 'like', '%'.@$_GET['search'].'%');
            })
            ->orderBy('id', 'desc')
            ->paginate(18)
            ->withPath('?search=' . @$_GET['search'] . '');

        return view('admin.income.record',['income_record'=>$income_record]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
       //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {

        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
